
var dToken;
$(document).ready(function () {
    try {
        //调用android客户端token
        dToken = androidbongURLShare.getToken();
    } catch (err) {
        try {
            //调用 iOS 让iOS把token 返回到 getIosToken方法中
            window.webkit.messageHandlers.GetIosToken.postMessage({body: 'getIosToken'});
        } catch (errr) {
            dToken = undefined;
        }
    }
    $.ajax({
        type: 'GET',
        url: "http://192.168.1.117:8080/root/participate/nums",
        success:function (result) {
            $(".person").text(count);
        }
    })
    $(".btn_commit").click(function () {
        // console.log(123);
        // alert(123);
        // window.location.href = 'activity.html';
        $.ajax({
            type:'POST',
            url:"http://192.168.1.117:8080/root/stepToMoney/status",
            data:{
                token:'AijSWommXaf-RGizEX-Zfi6m02oRESkUwdi6mLMU64iG'
            },
            success:function (result) {
                console.log(result);
                switch (result) {
                    case 1: console.log("正在参与活动");break;
                    case 2:
                        $(".model").show();
                        $(".txt1").text('抱歉，活仅限双十二购买');
                        $(".txt2").text('并绑定bong5 的用户');
                        break;
                    case 3: console.log("手环绑定的日期在活动之前");break;
                    case 4: console.log("手环已经参加过活动");break;
                    case 5: console.log("用户已经参加过的了");break;
                    case 0: console.log("新用户可以参加活动");break;
                }
            }

        })
    })
    $(".gomai").click(function () {
        window.location.href = 'https://mall.jd.com/index-1000007829.html';
    })

    $(".description").click(function () {
        window.location.href = "description.html"
    })
    $(".close").click(function () {
        $(".tips").hide();
        $(".model").hide();
    })

});

function getIosToken(data) {
    dToken = data;
}

var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "//hm.baidu.com/hm.js?800f0f35f4557a08958a37aa22f2d2b0";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();

var timestamp = $('#timestamp').text(),
    nonceStr = $('#nonceStr').text(),
    signature = $('#signature').text();

wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: 'wx4395d66b03a8f457', // 必填，公众号的唯一标识
    timestamp: timestamp, // 必填，生成签名的时间戳
    nonceStr: nonceStr, // 必填，生成签名的随机串
    signature: signature,// 必填，签名，见附录1
    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});

// 分享信息自定义
window.shareData = {
    "imgUrl": "http://bongads.b0.upaiyun.com/image/bong/yearend/wxshare-img.jpg",
    "timeLineLink": window.location.href,
    "tTitle": "bong 5用户集合！完成挑战赢取现金红包",
    "tContent": "12月 bong app 绑定 bong 5 的用户，即可参与现金挑战活动，完成挑战最多可获得120元+一个随机红包哦，快来吧！"
};

wx.ready(function () {
    wx.onMenuShareAppMessage({
        title: shareData.tTitle,
        desc: shareData.tContent,
        link: shareData.timeLineLink,
        imgUrl: shareData.imgUrl,
        success: function () {

        },
        cancel: function () {

        }
    });
    // 分享到朋友圈
    wx.onMenuShareTimeline({
        title: shareData.tTitle,
        link: shareData.timeLineLink,
        imgUrl: shareData.imgUrl,
        success: function () {
        },
        cancel: function () {
        }
    });

    // 分享到SQ
    wx.onMenuShareQQ({
        title: shareData.tTitle,
        desc: shareData.tContent,
        link: shareData.timeLineLink,
        imgUrl: shareData.imgUrl,
        success: function () {
        },
        cancel: function () {
        }
    });
});

